package club.yuyang.campus2mall.service.impl;

import club.yuyang.campus2mall.entity.User;
import club.yuyang.campus2mall.mapper.UserMapper;
import club.yuyang.campus2mall.service.UserService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {
    @Resource
    private UserMapper userMapper;

    @Override
    public User queryByAccountAndPassword(String account, String password) {
       return userMapper.queryByAccountAndPassword(account,password);
    }

    @Override
    public IPage<User> yhlbPage(Integer pagenum, Integer pagesize, String query) {
        Page<User> page = new Page<>(pagenum,pagesize);
        IPage<User> iPage = userMapper.selectPage(page,new QueryWrapper<User>().like("user_name",query));
        return iPage;
    }
}
